/*年轻人，只管向前看，不要管自暴自弃者的话*/

import 'package:intl/intl.dart';

///create by itz on 2024/1/9 17:22
///desc :
class TimeUtil {
  static bool stringIsNull(String? string) {
    bool isNull = string == null || string.isEmpty;
    return isNull;
  }

  static String validStr(String? str) {
    if (!stringIsNull(str)) {
      return str ?? '';
    }
    return '';
  }

  //计算到当前时间天数
  static String refreshTimeFormat(String? timeStr) {
    String str = validStr(timeStr);
    if (str.isEmpty) {
      return '';
    }

    DateTime dateTime = DateFormat('yyyy-MM-dd HH:mm:ss').parse(str);

    String formattedDateTime = DateFormat('yyyy-MM-dd').format(dateTime);

    return formattedDateTime;
  }
}
